package com.caac.core.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright caac 2006</p>
 * <p>Company: caac</p>
 * @author <a href="mailto:project@caac.com.cn">Project Group</a>
 * @version 1.0
 */

public class ActionSys {
    private static Map allMap = new HashMap();
    private static List rootList = new ArrayList();
    private static List branchList = new ArrayList();
    private static List leafList = new ArrayList();

    public static synchronized void add(ActionConf actionConf) {
        allMap.put(actionConf.getKey(), actionConf);
        if (actionConf.isAuthorized()) {
            if (actionConf.isRoot()) {
                rootList.add(actionConf);
            }
            if (actionConf.isBranch()) {
                branchList.add(actionConf);
            }
            if (actionConf.isLeaf()) {
                leafList.add(actionConf);
            }
        }
    }

    public static ActionConf getConf(String key) {
        return (ActionConf) allMap.get(key);
    }

    public static List getRootConfs() {
        return rootList;
    }

    public static List getBranchConfs() {
        return branchList;
    }

    public static List getLeafConfs() {
        return leafList;
    }
}
